package com.dt.dubai.core.filter;

import com.dt.dubai.core.comm.AesRequestWrapper;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


public class AesRequestFilter implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
       HttpServletRequest req=(HttpServletRequest) request;
        if (("POST").equals(req.getMethod())) {
            AesRequestWrapper aesRequestWrapper = new AesRequestWrapper(req, request.getParameterMap());
            filterChain.doFilter(aesRequestWrapper, response);
        }else {
            filterChain.doFilter(request, response);
        }
    }

    @Override
    public void destroy() {

    }
}
